@model ActivityLogSearchModel

@{
    //page title
    ViewBag.PageTitle = T("Admin.Customers.ActivityLog").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Activity logs");
}

@{
    const string hideSearchBlockAttributeName = "ActivityLogPage.HideSearchBlock";
    var hideSearchBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideSearchBlockAttributeName);
}

<div class="content-header clearfix">
    <h1 class="pull-left">
        @T("Admin.Customers.ActivityLog")
    </h1>
    <div class="pull-right">
        <form asp-controller="ActivityLog" asp-action="ClearAll" method="post">
            <button type="submit" id="clearall" name="clearall" class="btn bg-red">
                <i class="fa fa-trash-o"></i>
                @T("Admin.Customers.ActivityLog.Clear")
            </button>
            <nop-action-confirmation asp-button-id="clearall" />
            @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.ActivityLogListButtons })
        </form>
    </div>

</div>

<div class="content">
    <div class="form-horizontal">
        <div class="panel-group">
            <div class="panel panel-default panel-search">
                <div class="panel-body">
                    <div class="row search-row @(!hideSearchBlock ? "opened" : "")" data-hideAttribute="@hideSearchBlockAttributeName">
                        <div class="search-text">@T("Admin.Common.Search")</div>
                        <div class="icon-search"><i class="fa fa-search" aria-hidden="true"></i></div>
                        <div class="icon-collapse"><i class="fa fa-angle-down" aria-hidden="true"></i></div>
                    </div>

                    <div class="search-body @(hideSearchBlock ? "closed" : "")">

                        <div class="row">
                            <div class="col-md-5">
                                <div class="form-group">
                                    <div class="col-md-4">
                                        <nop-label asp-for="CreatedOnFrom" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-editor asp-for="CreatedOnFrom" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-md-4">
                                        <nop-label asp-for="CreatedOnTo" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-editor asp-for="CreatedOnTo" />
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                    <div class="col-md-4">
                                        <nop-label asp-for="ActivityLogTypeId" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-select asp-for="ActivityLogTypeId" asp-items="Model.ActivityLogType" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-md-4">
                                        <nop-label asp-for="IpAddress" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-editor asp-for="IpAddress" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-7 col-md-offset-5">
                                <button type="button" id="search-log" class="btn btn-primary btn-search">
                                    <i class="fa fa-search"></i>
                                    @T("Admin.Common.Search")
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-body">
                    @await Html.PartialAsync("Table", new DataTablesModel
                    {
                        Name = "activityLog-grid",
                        UrlRead = new DataUrl("ListLogs", "ActivityLog", null),
                        UrlDelete = new DataUrl("ActivityLogDelete", "ActivityLog", null),
                        SearchButtonId = "search-log",
                        Length = Model.PageSize,
                        LengthMenu = Model.AvailablePageSizes,
                        Filters = new List<FilterParameter>
                        {
                            new FilterParameter(nameof(Model.CreatedOnTo)),
                            new FilterParameter(nameof(Model.CreatedOnFrom)),
                            new FilterParameter(nameof(Model.IpAddress)),
                            new FilterParameter(nameof(Model.ActivityLogTypeId))
                        },
                        ColumnCollection = new List<ColumnProperty>
                        {
                            new ColumnProperty(nameof(ActivityLogModel.ActivityLogTypeName))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.ActivityLogType").Text,
                                Width = "200"
                            },
                            new ColumnProperty(nameof(ActivityLogModel.CustomerEmail))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.CustomerEmail").Text,
                                Width = "100",
                                Render = new RenderLink(new DataUrl("~/Admin/Customer/Edit", nameof(ActivityLogModel.CustomerId)))
                            },
                            new ColumnProperty(nameof(ActivityLogModel.IpAddress))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.IpAddress").Text,
                                Width = "100"
                            },
                            new ColumnProperty(nameof(ActivityLogModel.Comment))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.Comment").Text
                            },
                            new ColumnProperty(nameof(ActivityLogModel.CreatedOn))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.CreatedOn").Text,
                                Width = "200",
                                Render = new RenderDate()
                            },
                            new ColumnProperty(nameof(ActivityLogModel.Id))
                            {
                                Title = T("Admin.Common.Delete").Text,
                                Width = "100",
                                Render = new RenderButtonRemove(T("Admin.Common.Delete").Text),
                                ClassName = NopColumnClassDefaults.Button
                            }
                        }
                    })
                </div>
            </div>
        </div>
    </div>
</div>